package com.oj;

import java.util.Arrays;
import java.util.Scanner;

public class UnionFindSet {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int numNode = scanner.nextInt();
            int numQuery = scanner.nextInt();
            // 边的个数是顶点树-1
            Edge[] edges = new Edge[numNode - 1];
            // 初始化树的边
            for (int i = 0; i < numNode - 1; i++) {
                edges[i] = new Edge(scanner.nextInt(), scanner.nextInt(),
                        scanner.nextInt());
            }
            // 查询数组
            int[] queries = new int[numQuery];
            for (int i = 0; i < numQuery; i++) {
                queries[i] = scanner.nextInt();
            }

        }
    }

    /**
     * 每次查询返回一个结果
     *
     * @param edges
     * @param query
     * @return
     */
    public static int solver(Edge[] edges, int query, int numNode) {
        int res = 0;
        // 1.按照权值从大到小的顺序对边进行排序
        Arrays.sort(edges, ((o1, o2) -> {
            if (o1.weight > o2.weight) {
                return -1;
            } else if (o1.weight == o2.weight) {
                return 0;
            } else {
                return 1;
            }
        }));
        // 2.使用并查集，将点进行分组
        int[] father = new int[numNode - 1];
        // 节点初始化所有节点的父节点都是-1

        return res;
    }
}

/**
 * 自定义树的边类
 */
class Edge {
    int start;
    int end;
    int weight;

    public Edge(int start, int end, int weight) {
        this.start = start;
        this.end = end;
        this.weight = weight;
    }
}
